using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Line : MonoBehaviour, IInteractable
{
    private bool isConnect;
    private LineRenderer lineRenderer => GetComponent<LineRenderer>();
    private bool finishConnect;

    private void ConnectLine()
    {
        isConnect = true;
        if (LineManager.Instance.lineList.Count == 0)
        {
            LineManager.Instance.lineList.Add(this);
        }
        else
        {
            Line line = LineManager.Instance.lineList[LineManager.Instance.Count - 1];
            lineRenderer.SetPosition(0, line.transform.position);
            lineRenderer.SetPosition(1, transform.position);
            LineManager.Instance.lineList.Add(this);
        }
    }

    public void InteractAction()
    {
        if (isConnect)
        {
            LineManager.Instance.lineList = new List<Line>();
            finishConnect = true;
        }

        if (!finishConnect)
        {
            ConnectLine();
            isConnect = true;
        }

    }

    public void EndINteractACtion()
    {
        
    }
}